package com.lan.ai.mutimodelEmbedding;

import cn.hutool.core.util.ObjectUtil;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.ai.embedding.EmbeddingOptions;
import org.springframework.ai.embedding.EmbeddingRequest;

import java.util.List;

/**
 * @author lanyanhua
 * @date 2025/1/21 11:15
 * @description
 */
@Getter
@Setter
@Accessors(chain = true)
public class MutimodelEmbeddingRequest extends EmbeddingRequest {

    private String model;

    private Input input;
    public MutimodelEmbeddingRequest() {
        super(null,null);
    }

    public MutimodelEmbeddingRequest(List<String> inputs, EmbeddingOptions options) {
        super(inputs, options);
    }


    @Data
    public static class Input{
        private List<Contents> contents;
    }

    @Data
    public static class Contents {
        private String text;
        private String image;
        private String vedio;

        public String getText() {
            return ObjectUtil.isEmpty(text)?null : text;
        }
    }


    public static Contents contents(String text, String image, String vedio) {
        return new Contents() {{
            setText(text);
            setImage(image);
            setVedio(vedio);
        }};
    }

    public static Contents text(String text) {
        return new Contents() {{
            setText(text);
        }};
    }

    public static Contents image(String text) {
        return new Contents() {{
            setImage(text);
        }};
    }

    public static Contents vedio(String text) {
        return new Contents() {{
            setVedio(text);
        }};
    }

    public static MutimodelEmbeddingRequest of(String model, Contents... contents) {
        MutimodelEmbeddingRequest request = new MutimodelEmbeddingRequest(null,null);
        request.setModel(model);
        request.setInput(new Input(){{setContents(List.of(contents));}});
        return request;
    }
}
